// nest中三种参数方式
// 1.Param：restful api 的方式
// 2.Query：get请求，也就是url的参数
// 3.Body：post的参数
import { Controller, Get,Post,Put,Delete, Param, Body,Query,UseFilters } from '@nestjs/common';
import { AppService } from './app.service';
import { TestService } from './test.service';
import { HttpExceptionFilter } from './exception/http-exception.filter';


@Controller()
export class AppController {
  constructor(private readonly appService: AppService,private readonly testService: TestService) {}
  

  @Get()
  @UseFilters(HttpExceptionFilter)
  getHello(): string {
    return this.appService.getHello();
  }

  @Get('/test')
  @UseFilters(HttpExceptionFilter)
  getTest(): string { 
    return this.testService.getTest();
  }

  //get:获取数据
  //post:插入、新增数据
  //put:更新数据
  //delete:删除数据
  @Get('/data/:id')
  @UseFilters(HttpExceptionFilter)
  getData(@Param() params): string {

    return this.testService.getData(params)
  }
  @Get('/data')
  @UseFilters(HttpExceptionFilter)
  getAllData(): string {
    return this.testService.getAllData()
  }
  @Post('/data')
  @UseFilters(HttpExceptionFilter)
  addData(@Body() body,@Query() query): string {
    return this.testService.addData(body,query)
  }

  @Put('/data/:id')
  @UseFilters(HttpExceptionFilter)
  updateData(): string {
    return this.testService.updateData()
  }
  @Delete('/data/:id')
  @UseFilters(HttpExceptionFilter)
  deleteData(): string {
    return this.testService.deleteData()
  }

}
